package com.ruoyi.system.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author: Zhangyuting
 * @Desctription: TODO
 * @Date: Created in 2025/3/12 20:48
 * @Version: 1.0
 */
//@Configuration
public class WebMvcConfig  implements WebMvcConfigurer {
    //服务器支持跨域
//    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("http://192.168.1.122",
                        "http://192.168.1.132",
//                        "http://127.0.0.1",
                        "http://www.imisinfo.cn/"
                )  // 允许来自http://localhost:8081的请求
                .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") // 允许的方法
                .allowedHeaders("*")
                .exposedHeaders("Access-Control-Allow-Headers",
                        "Access-Control-Allow-Methods",
                        "Access-Control-Allow-Origin",
                        "Access-Control-Max-Age",
                        "X-Frame-Options")
                .allowCredentials(false)
                .maxAge(3600);
    }
}
